<?php

namespace app\api\logic;

use app\common\exception\LogicException;
use app\common\model\Agreement;

class AgreementLogic
{
    protected Agreement $model;

    public function __construct()
    {
        $this->model = new Agreement();
    }

    public function getList()
    {
        return $this->model
            ->field('id,title,content,note,create_time')
            ->where('delete_time', null)
            ->select();
    }

    public function detail(int $id)
    {
        $info = $this->model->field('id,content,create_time')
            ->where('id',$id)
            ->where('delete_time',null)
            ->find();
        if (!$info) {
            throw new LogicException('数据不存在',400);
        }

        return $info;
    }

}